﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Role {
    public GameObject obj;
    public int position;//角色位置，0代表from，1代表to，2代表boat
    public int boatPos;//船位置，0为from，1为to
    private Move move;
    private Vector3 PosFrom;//角色在From河岸上的位置
    private Vector3 PosTo;//角色在To河岸上的位置
    public Role(string name)
    {
        obj = Object.Instantiate(Resources.Load(name, typeof(GameObject)), Vector3.zero, Quaternion.identity, null) as GameObject;
        position = 0;
        move = obj.AddComponent(typeof(Move)) as Move;
    }

    public void setName(string name)
    {
        obj.name = name;
    }
    //设置角色在河岸上的位置
    public void setFromPos(Vector3 vec)
    {
        obj.transform.position = vec;
        PosFrom = vec;
    }
    public void setToPos(Vector3 vec)
    {
        PosTo = vec;
    }

    //记录船的位置
    public void setBoatPos(int i)
    {
        boatPos = i;
    }
    //记录角色的位置
    public void setPos(int i)
    {
        position = i;
    }
    //将角色移动回河岸
    public Vector3 getGroundPos(int i)
    {
        if(i == 0){
            return PosFrom;
        } else {
            return PosTo;
        }
    }

}